import java.io.*;
import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: Marina
 * Date: 10/5/13
 * Time: 7:24 PM
 * To change this template use File | Settings | File Templates.
 */
public class linePrint {
    public String input;
    public int number;
    public ArrayList<String> eachLine;

    public static void main(String[] args) {
        linePrint printer = new linePrint();
        printer.setNumber(printer.getUserInput("type number of stars"));
        printer.printNStarsCenteredTriangle();
    }

    public void setNumber(String input) {
        this.number = Integer.parseInt(input);
    }

    public void printNStarsCenteredTriangle() {
        this.createArrayListOfAsteriscs(this.number);
        this.prependSpacesForCentering(this.eachLine);
        this.appendNewLine(this.eachLine);
        this.printArrayList(this.eachLine);
    }

    public void printArrayList(ArrayList<String> linesArray) {
        for(String asteriscs: linesArray){
            System.out.print(asteriscs);
        }
    }

    public void prependSpacesForCentering(ArrayList<String> linesArray) {
        for(String asteriscs: linesArray){
            int index = linesArray.indexOf(asteriscs);
            int numSpaces   = linesArray.size() - index - 1;
            String spaces = "";
            for(int i = 0; i < numSpaces; i++)   {
                spaces = spaces + " ";
            }
            linesArray.set(index, spaces + asteriscs);
        }
        this.eachLine = linesArray;
    }

    public void appendNewLine(ArrayList<String> linesArray) {
        for(String asteriscs: linesArray) {
            int index = linesArray.indexOf(asteriscs);
            linesArray.set(index, "\n" + asteriscs);
        }
        this.eachLine = linesArray;
    }

    public void createArrayListOfAsteriscs(int number){
        ArrayList<String> asteriscsArray = new ArrayList<String>();
        for(int i = 0; i < number*2; i++) {
            if(i%2 == 0){
                String theAsteriscs = "";
                for(int x = 0; x <= i; x++) {
                    theAsteriscs = theAsteriscs + "*";
                }
                asteriscsArray.add(theAsteriscs);
            }
        }
        this.eachLine = asteriscsArray;
    }

    public String getUserInput(String prompt) {
        String inputLine = null;
        System.out.print(prompt + " ");
        try {
            BufferedReader inputStream = new BufferedReader(new InputStreamReader(System.in));
            inputLine = inputStream.readLine();
            if(inputLine.length() == 0) return null;
        } catch (IOException e) {
            System.out.println("IOException: " + e);
        }
        return inputLine;
    }
}
